import Taro, { Component } from "@tarojs/taro";
import { View } from "@tarojs/components";
import {
    AtNoticebar
} from "taro-ui";

import Immutable from 'immutable'

class NoticeBar extends Component {
    static defaultProps={
        checkPlan:{
            currentMission:undefined
        },
        user:{
            specialWords:[]
        }
    }
  shouldComponentUpdate(props){
    return !Immutable.is(props.checkPlan.currentMission,this.props.checkPlan.currentMission)
        ||!Immutable.is(props.user.specialWords,this.props.user.specialWords);
  }
  render() {
    let words=this.props.user.specialWords;
    return (
      <View>
        <AtNoticebar
          marquee
          speed={50}
          single
        >
          {this.props.checkPlan.currentMission?`${words.length===0?'正在进行：':words[2][0]}${this.props.checkPlan.currentMission+(words.length===0?'':words[2][1])}`:words.length===0?'我们的征途，是星辰大海⭐':words[3]}
        </AtNoticebar>
      </View>
    );
  }
}

export default NoticeBar;
